package com.ysd.lis.task;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ysd.lis.entity.SysInterface;
import com.ysd.lis.mapper.sys.SysInterfaceMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;


/**
 * his30分钟未推送危急值
 *
 * @author wanghao
 * @create 2024/9/5 0005
 */
@Component("sqlview")
@Slf4j
public class SqlView {
    @Autowired
    SysInterfaceMapper sysInterfaceMapper;
    public void criticalReportPush() {
        //调用发送微生物报告接口
        LambdaQueryWrapper<SysInterface> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysInterface::getDelFlag, 0);
        wrapper.eq(SysInterface::getIsEnable, 1);
        List<SysInterface> sysInterfaces = sysInterfaceMapper.selectList(wrapper);
        List<String> collect = sysInterfaces.stream().filter(o -> Objects.nonNull(o) && StringUtils.isNotBlank(o.getInterfaceUrl())).map(SysInterface::getInterfaceUrl).distinct().collect(Collectors.toList());
        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(collect)) {
            /*发布报告相关*/
            for (String webUrl : collect) {
                System.out.println(webUrl);
            }
        }
        // 当前时间
        LocalDateTime now = LocalDateTime.now();
        System.out.println(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    }

}
